<?php
/**
 * Created by PhpStorm.
 * User: Hanson
 * Date: 2016/7/24
 * Time: 22:28
 */

namespace App\Handlers;


//use App\Models\Message;

use Carbon\Carbon;
use EasyWeChat\Message\Transfer;
use GuzzleHttp\Client;

class TextHandler implements HandlerInterface
{

    public static function run($message)
    {
        if($message->Content === '客服'){
            return new Transfer();
        }
        $client = new Client();
        $response = $client->get('http://www.tuling123.com/openapi/api', [
            'query' => [
                'key' => getenv('TU_LING_KEY'),
                'info' => $message->Content
            ]
        ]);

        $content = $response->getBody()->getContents();
        return json_decode($content)->text . '[小哥自动回复]';
    }
}
